package com.kingyea.app.market.utils;

import com.alibaba.fastjson.JSONException;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class HttpUtil {

    public static String httpProcess(HttpServletRequest request) throws IOException, JSONException {
        StringBuffer sb = new StringBuffer();
        InputStream is = request.getInputStream();
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(is, GlobalVar.CHARSET_UTF8));
            String s = "";
            while ((s = br.readLine()) != null) {
                sb.append(s);
            }
            if (sb.toString().length() <= 0) {
                return null;
            } else {
                return sb.toString();
            }
        } finally {
            if (sb != null) {
                is.close();
            }
        }

    }

}